package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TProprietor;
import com.ruoyi.system.service.ITProprietorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * illustriousness.`t_proprietor`Controller
 *
 * @author ruoyi
 * @date 2022-11-29
 */
@RestController
@RequestMapping("/system/proprietor")
public class TProprietorController extends BaseController
{
    @Autowired
    private ITProprietorService tProprietorService;


    /**
     * 查询illustriousness.`t_proprietor`列表
     */
    @PreAuthorize("@ss.hasPermi('system:proprietor:list')")
    @GetMapping("/list")
    public TableDataInfo list(TProprietor tProprietor)
    {
        startPage();
        List<TProprietor> list = tProprietorService.selectTProprietorList(tProprietor);
        return getDataTable(list);
    }

    /**
     * 导出illustriousness.`t_proprietor`列表
     */
    @PreAuthorize("@ss.hasPermi('system:proprietor:export')")
    @Log(title = "illustriousness.`t_proprietor`", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TProprietor tProprietor)
    {
        List<TProprietor> list = tProprietorService.selectTProprietorList(tProprietor);
        ExcelUtil<TProprietor> util = new ExcelUtil<TProprietor>(TProprietor.class);
        util.exportExcel(response, list, "illustriousness.`t_proprietor`数据");
    }

    /**
     * 获取illustriousness.`t_proprietor`详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:proprietor:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tProprietorService.selectTProprietorById(id));
    }

    /**
     * 新增illustriousness.`t_proprietor`
     */
    @PreAuthorize("@ss.hasPermi('system:proprietor:add')")
    @Log(title = "illustriousness.`t_proprietor`", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TProprietor tProprietor)
    {
        return toAjax(tProprietorService.insertTProprietor(tProprietor));
    }

    /**
     * 修改illustriousness.`t_proprietor`
     */
    @PreAuthorize("@ss.hasPermi('system:proprietor:edit')")
    @Log(title = "illustriousness.`t_proprietor`", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TProprietor tProprietor)
    {
        return toAjax(tProprietorService.updateTProprietor(tProprietor));
    }

    /**
     * 删除illustriousness.`t_proprietor`
     */
    @PreAuthorize("@ss.hasPermi('system:proprietor:remove')")
    @Log(title = "illustriousness.`t_proprietor`", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tProprietorService.deleteTProprietorByIds(ids));
    }

}
